package com.bestdreamer.url;

public class MultiThreadDown {

    public static void main(String[] args) throws Exception{
        // 初始化 DownUtil 对象
        final DownUtil downUtil = new DownUtil("https://akamai.bintray.com/bb/bba60a428386dfcedc094659b1369e6760ae15d23d4c411835fbf38b8f14315d" +
                "?__gda__=exp=1523168412~hmac=9306c25d5e860cb575776b9634c94728e2c83aa52df429f26174a8b822366725" +
                "&response-content-disposition=attachment%3Bfilename%3D%22","netty-4.1.23.Final.tar.bz2",4);
        // 开始已下载
        downUtil.download();
        new Thread(){
            public void run(){
                while(downUtil.getCompleteRate() < 1){
                    // 每隔 0.1 秒查询一次任务的完成进度
                    // GUI 程序中可根据该进度来绘制进度条
                    System.out.println("已完成："+downUtil.getCompleteRate());
                    try{
                        Thread.sleep(1000);
                    }catch (Exception e){
                        e.printStackTrace();
                    }
                }
            }
        }.start();
    }
}
